package com.woorigil.social.domain.deal;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.woorigil.social.domain.SqlMapDaoSupport;

@Repository
public class RecentViewDao extends SqlMapDaoSupport<RecentView, Integer> {
	public static final String NAMESPACE = "RecentView";

	@Override
	public String getNamespace() {
		return NAMESPACE;
	}
	
	public RecentView selectByDeal(String sid, int dealId) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("sid", sid);
		params.put("dealId", dealId);
		return (RecentView)getSqlMapClientTemplate().queryForObject(getStatementName(NAMESPACE, "selectByDeal"), params);
	}

	@SuppressWarnings("unchecked")
	public List<RecentView> search(String sid, int offset) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("sid", sid);
		params.put("offset", offset);		
		return getSqlMapClientTemplate().queryForList(getStatementName(NAMESPACE, "search"), params);
	}
}